package top.fengyulou.common;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Jr {
    /**
     * 状态
     */
    private boolean status;
    /**
     * 消息
     */
    private String msg;
    /**
     * 数据
     */
    private Object data;

    public Jr(boolean status) {
        this.status = status;
    }

    public Jr(boolean status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public Jr(boolean status, Object data) {
        this.status = status;
        this.data = data;
    }

    public Jr(boolean status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 正确返回
     *
     * @return
     */
    public static Jr yes() {
        return new Jr(true);
    }

    /**
     * 正确返回，带提示消息
     *
     * @param msg
     * @return
     */
    public static Jr yes(String msg) {
        return new Jr(true, msg);
    }

    /**
     * 正确返回，带返回数据
     *
     * @param data
     * @return
     */
    public static Jr yes(Object data) {
        return new Jr(true, data);
    }

    /**
     * 正确返回，带提示消息和返回数据
     *
     * @param msg
     * @param data
     * @return
     */
    public static Jr yes(String msg, Object data) {
        return new Jr(true, msg, data);
    }

    /**
     * 错误返回
     *
     * @return
     */
    public static Jr no() {
        return new Jr(false);
    }

    /**
     * 错误返回，带提示消息
     *
     * @param msg
     * @return
     */
    public static Jr no(String msg) {
        return new Jr(false, msg);
    }

    /**
     * 错误返回，带返回数据
     *
     * @param data
     * @return
     */
    public static Jr no(Object data) {
        return new Jr(false, data);
    }

    /**
     * 错误返回，带提示消息和返回数据
     *
     * @param msg
     * @param data
     * @return
     */
    public static Jr no(String msg, Object data) {
        return new Jr(false, msg, data);
    }

    /**
     * 失败
     */
    public boolean fail() {
        return status == false;
    }
}
